package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 应用单字段
 * @author 代码创建
 */
public class FSysAppFormFields extends AbstractTableBean {

    private int SysId; //租户ID
    private String SysAddTime; //创建时间
    private String SysAddUser; //创建人
    private String SysEditTime; //修改时间
    private String SysEditUser; //修改人
    private String FieldDesc; //字段描述
    private String FieldName; //字段名
    private String AppKeyId; //应用KeyId

    public static String TABLE_NAME = "F_Sys_AppFormFields";
    public static String TABLEKEY_NAME = "FieldId";
    public FSysAppFormFields (IntegrateSql f){
        super(f,TABLE_NAME);
        this.setKeyName(TABLEKEY_NAME);
    }

    public FSysAppFormFields (IntegrateSql f,ResultSet rs) throws SQLException{
        super(f,TABLE_NAME);
        this.setKeyName(TABLEKEY_NAME);
        this.initParamToRs(rs);
    }

    public FSysAppFormFields (IntegrateSql f,String keyValue) throws SQLException{
        super(f,TABLE_NAME);
        this.setKeyName(TABLEKEY_NAME);
        setCodePrepare(selectCodeById().toString());
        prepareSql.setPstValue(1, keyValue);
        ResultSet rs = executeQuery();
        if(rs.next()){
            initParamToRs(rs);
        }else{
            initParam();
        }
        rs.close();
    }

    @Override
    protected void initParam() {
        SysId = 0; //租户ID
        SysAddTime = ""; //创建时间
        SysAddUser = ""; //创建人
        SysEditTime = ""; //修改时间
        SysEditUser = ""; //修改人
        FieldDesc = ""; //字段描述
        FieldName = ""; //字段名
        AppKeyId = ""; //应用KeyId
    }


    public void initParamToRs(ResultSet rs) throws SQLException{
        SysId = rs.getInt("SysId"); //租户ID
        SysAddTime = rs.getString("SysAddTime"); //创建时间
        SysAddUser = rs.getString("SysAddUser"); //创建人
        SysEditTime = rs.getString("SysEditTime"); //修改时间
        SysEditUser = rs.getString("SysEditUser"); //修改人
        FieldDesc = rs.getString("FieldDesc"); //字段描述
        FieldName = rs.getString("FieldName"); //字段名
        AppKeyId = rs.getString("AppKeyId"); //应用KeyId
        this.setKeyId(rs.getString("FieldId"));
    }


    @Override
    protected int appendData() throws SQLException {
        int i = 1;
        prepareSql.setPstValue(i++,SysId); //租户ID
        prepareSql.setPstValue(i++,SysAddTime); //创建时间
        prepareSql.setPstValue(i++,SysAddUser); //创建人
        prepareSql.setPstValue(i++,SysEditTime); //修改时间
        prepareSql.setPstValue(i++,SysEditUser); //修改人
        prepareSql.setPstValue(i++,FieldDesc); //字段描述
        prepareSql.setPstValue(i++,FieldName); //字段名
        prepareSql.setPstValue(i++,AppKeyId); //应用KeyId
        return i;
    }


    @Override
    public Vector<String> getFields() {
        Vector<String> vec = new Vector<String>();
        vec.addElement("SysId"); //租户ID
        vec.addElement("SysAddTime"); //创建时间
        vec.addElement("SysAddUser"); //创建人
        vec.addElement("SysEditTime"); //修改时间
        vec.addElement("SysEditUser"); //修改人
        vec.addElement("FieldDesc"); //字段描述
        vec.addElement("FieldName"); //字段名
        vec.addElement("AppKeyId"); //应用KeyId
        return vec;
    }


    /**
     * 设置租户ID
     * @param sysid
     */
    public void setSysId(int sysid){
        SysId = sysid;
    }
    /**
     * 获取SysId
     * @return 租户ID
     */
    public int getSysId(){
        return SysId;
    }

    /**
     * 设置创建时间
     * @param sysaddtime
     */
    public void setSysAddTime(String sysaddtime){
        SysAddTime = sysaddtime;
    }
    /**
     * 获取SysAddTime
     * @return 创建时间
     */
    public String getSysAddTime(){
        return SysAddTime;
    }

    /**
     * 设置创建人
     * @param sysadduser
     */
    public void setSysAddUser(String sysadduser){
        SysAddUser = sysadduser;
    }
    /**
     * 获取SysAddUser
     * @return 创建人
     */
    public String getSysAddUser(){
        return SysAddUser;
    }

    /**
     * 设置修改时间
     * @param sysedittime
     */
    public void setSysEditTime(String sysedittime){
        SysEditTime = sysedittime;
    }
    /**
     * 获取SysEditTime
     * @return 修改时间
     */
    public String getSysEditTime(){
        return SysEditTime;
    }

    /**
     * 设置修改人
     * @param sysedituser
     */
    public void setSysEditUser(String sysedituser){
        SysEditUser = sysedituser;
    }
    /**
     * 获取SysEditUser
     * @return 修改人
     */
    public String getSysEditUser(){
        return SysEditUser;
    }

    /**
     * 设置字段描述
     * @param fielddesc
     */
    public void setFieldDesc(String fielddesc){
        FieldDesc = fielddesc;
    }
    /**
     * 获取FieldDesc
     * @return 字段描述
     */
    public String getFieldDesc(){
        return FieldDesc;
    }

    /**
     * 设置字段名
     * @param fieldname
     */
    public void setFieldName(String fieldname){
        FieldName = fieldname;
    }
    /**
     * 获取FieldName
     * @return 字段名
     */
    public String getFieldName(){
        return FieldName;
    }

    /**
     * 设置应用KeyId
     * @param appkeyid
     */
    public void setAppKeyId(String appkeyid){
        AppKeyId = appkeyid;
    }
    /**
     * 获取AppKeyId
     * @return 应用KeyId
     */
    public String getAppKeyId(){
        return AppKeyId;
    }

}
